package com.tudouji.project.noticeinfo.controller;

import java.util.List;

import com.flow.service.pojo.flow.FlowTaskDetail;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tudouji.framework.aspectj.lang.annotation.Log;
import com.tudouji.framework.aspectj.lang.enums.BusinessType;
import com.tudouji.project.noticeinfo.domain.Noticeinfo;
import com.tudouji.project.noticeinfo.service.INoticeinfoService;
import com.tudouji.framework.web.controller.BaseController;
import com.tudouji.framework.web.domain.AjaxResult;
import com.tudouji.common.utils.poi.ExcelUtil;
import com.tudouji.framework.web.page.TableDataInfo;

/**
 * 通知记录Controller
 * 
 * @author tudouji
 * @date 2021-04-13
 */
@RestController
@RequestMapping("/noticeinfo/noticeinfo")
public class NoticeinfoController extends BaseController
{
    @Autowired
    private INoticeinfoService noticeinfoService;

    /**
     * 查询通知记录列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Noticeinfo noticeinfo,String userId)
    {
        startPage();
//        List<Noticeinfo> list = noticeinfoService.selectNoticeinfoList(noticeinfo);
        List<FlowTaskDetail> list = noticeinfoService.selectNuHandleInfo(userId, null);
        return getDataTable(list);
    }


    /**
     * 查询通知记录列表
     */
    @GetMapping("/toDoList")
    public TableDataInfo toDoList(String userId) {
        startPage();
        List<FlowTaskDetail> list = noticeinfoService.selectNuHandleInfo(userId);
        return getDataTable(list);
    }

    /**
     * 导出通知记录列表
     */
    @PreAuthorize("@ss.hasPermi('noticeinfo:noticeinfo:export')")
    @Log(title = "通知记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Noticeinfo noticeinfo)
    {
        List<Noticeinfo> list = noticeinfoService.selectNoticeinfoList(noticeinfo);
        ExcelUtil<Noticeinfo> util = new ExcelUtil<Noticeinfo>(Noticeinfo.class);
        return util.exportExcel(list, "noticeinfo");
    }

    /**
     * 获取通知记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('noticeinfo:noticeinfo:query')")
    @GetMapping(value = "/{autoid}")
    public AjaxResult getInfo(@PathVariable("autoid") Long autoid)
    {
        return AjaxResult.success(noticeinfoService.selectNoticeinfoById(autoid));
    }

    /**
     * 新增通知记录
     */
    @PreAuthorize("@ss.hasPermi('noticeinfo:noticeinfo:add')")
    @Log(title = "通知记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Noticeinfo noticeinfo)
    {
        return toAjax(noticeinfoService.insertNoticeinfo(noticeinfo));
    }

    /**
     * 修改通知记录
     */
    @PreAuthorize("@ss.hasPermi('noticeinfo:noticeinfo:edit')")
    @Log(title = "通知记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Noticeinfo noticeinfo)
    {
        return toAjax(noticeinfoService.updateNoticeinfo(noticeinfo));
    }

    /**
     * 删除通知记录
     */
    @PreAuthorize("@ss.hasPermi('noticeinfo:noticeinfo:remove')")
    @Log(title = "通知记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{autoids}")
    public AjaxResult remove(@PathVariable Long[] autoids)
    {
        return toAjax(noticeinfoService.deleteNoticeinfoByIds(autoids));
    }
}
